import { GoodListRequestDataType } from "@/types/category";
import httpInstance from "@/utils/http";

// 获取Category页面下分类数据
export const getCategoryAPI = function (id: string) {
    // 用于取消请求的控制器
    const controller = new AbortController();
    // 进行请求
    const response = httpInstance({
        url: '/category',
        params: { id },
        signal: controller.signal,
    });
    return { response, controller };
};

// 获取SubCategory页面下面包屑导航数据
export const getCategoryFilterAPI = function (id: string) {
    // 用于取消请求的控制器
    const controller = new AbortController();
    // 进行请求
    const response = httpInstance({
        url: '/category/sub/filter',
        params: { id },
        signal: controller.signal,
    });
    return { response, controller };
};

// 获取SubCategory页面下商品列表
export const getSubCategoryGoodListAPI = function (data: GoodListRequestDataType) {
    return httpInstance({
        url: '/category/goods/temporary',
        method: 'POST',
        data,
    });
};